//
//  Car.m
//  car
//
//  Created by chenxu on 15/3/12.
//  Copyright (c) 2015年 chenxu. All rights reserved.
//

#import "Car.h"
#import "Login.h"
@interface Car(){
    NSArray *arr;
}
@end

@implementation Car


- (instancetype)init
{
    self = [super init];
    if (self) {
        self.Carpinpai = @"";
        self.Carxinghao = @"";
        self.Carbuydate = @"";
        self.Carfadongjiid = @"";
        self.Carchejiahao = @"";
        self.Carprice = @"";
        self.Carbaoxiandaoqi = @"";
        self.Carid = @"";
        arr = @[@"车牌号:",@"品牌:",@"车型:",@"发动机号:",@"车架号:",@"保险到期日期:",@"注册登记日期:",@"购车价格:"];
    }
    return self;
}

- (int)numberOfRow{
    return (int)arr.count;
}

- (NSString*)titleAtIndex:(int)index{
    if (index>=0 && index <arr.count) {
        return [arr objectAtIndex:index];
    }
    else{
        return @"";
    }
}
- (NSString*)contentAtIndex:(int)index{
    if (index>=0 && index <arr.count) {
        NSString* str;
        if (index==0) {
            str = _Carid;
        }
        else if(index == 1){
            str = _Carpinpai;
        }
        else if (index == 2){
            str = _Carxinghao;
        }
        else if (index == 3){
            str = _Carfadongjiid;
        }
        else if (index == 4){
            str = _Carchejiahao;
        }
        else if (index == 5){
            str = _Carbaoxiandaoqi;
        }
        else if (index == 6){
            str = _Carbuydate;
        }
        else{
            str = _Carprice;
        }
        return str;
    }
    else
    {
        return @"";
    }
}

/*!
 *  @brief  添加修改车辆信息的post数据
 *  @return 数据字典
 */
- (NSDictionary*)toAddParams{
    return @{@"Carpinpai":_Carpinpai,
             @"Carxinghao":_Carxinghao,
             @"Carbuydate" : _Carbuydate,
             @"Carfadongjiid" : _Carfadongjiid,
             @"Carchejiahao" : _Carchejiahao,
             @"Carprice" : _Carprice,
             @"Carbaoxiandaoqi" : _Carbaoxiandaoqi,
             @"Carid" : _Carid,//哪个id?
             @"Uid" : [Login curLoginUser].Uid,
             @"Username" : [Login curLoginUser].Username
             };
}

- (NSDictionary*)toModifyParams{
    return @{@"Carpinpai":_Carpinpai,
             @"Carxinghao":_Carxinghao,
             @"Carbuydate" : _Carbuydate,
             @"Carfadongjiid" : _Carfadongjiid,
             @"Carchejiahao" : _Carchejiahao,
             @"Carprice" : _Carprice,
             @"Carbaoxiandaoqi" : _Carbaoxiandaoqi,
             @"Carid" : _Carid,
             @"Cid" :_Cid
             };
}

- (NSDictionary*)toDeleteParams{
    return @{@"Cid":_Cid};
}

- (NSString*)tips{
    NSString *tipStr = nil;
    if (!self.Carid || self.Carid.length <= 0){
        tipStr = @"您还没填写车牌号";
    }
    if (!_Carbaoxiandaoqi || !_Carbuydate || !_Carchejiahao || !_Carfadongjiid || !_Carpinpai || !_Carprice || !_Carxinghao){
        tipStr = @"请把车辆信息填写完整，我们才好进行精确评估";
    }
    return tipStr;
}

@end
